//
//  WhTGameBox.m
//  ProjectM
//
//  Created by ris on 11-3-24.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "WhTGameBox.h"
#import "WhTDef.h"

@interface WhTGameBox ()

- (void)initStage:(int)s;
- (void)renderStage:(NSArray *)s;

@end


@implementation WhTGameBox

- (id)init
{
	if(self = [super init])
	{ 
		//stage_		= [[WhTStage alloc] init];
//		stageIndex_ = -1;
//		[self renderStage:stage_.s1];
		aa = [[WhTSprite alloc] initWithPaths:@"acts.png",@"background1.png",nil];
		bb = [[WhTSprite alloc] initWithPaths:@"background1.png",nil];
	}
	return self;
}

- (void)render
{
	//NSEnumerator *enume = [liveObjs_ objectEnumerator];
//	id obj;
//	while (obj = [enume nextObject]) 
//	{
//		[obj render];
//	}
	aa.position = WhTPointMake(0.0f, 0.0f, -3.0f);
	bb.position = WhTPointMake(0.0f, 0.0f, -3.5f);
		[bb render];
	[aa render];

	//[ECCAST(WhTSprite,[liveObjs_ objectForKey:@"mushroom"]) render];
//	[ECCAST(WhTSprite,[liveObjs_ objectForKey:@"background1"]) render];
}

- (void)renderStage:(NSArray *)s
{
	if (liveObjs_ != nil) 
	{
		[liveObjs_ release], liveObjs_ = nil;
	}
	liveObjs_ = [WhTSpriteFactory createWithStageInfo:s 
																			outStageIndex:&stageIndex_];
	[self initStage:stageIndex_];
}

- (void)initStage:(int)s
{
	switch (s) {
		case 1:
			ECCAST(WhTSprite,[liveObjs_ objectForKey:@"mushroom"]).position = WhTPointMake(0.0f, 0.0f, -4.0f);
			ECCAST(WhTSprite,[liveObjs_ objectForKey:@"mushroom"]).scale = WhTPointMake(1.0f, 1.0f, 1.0f);
			
			ECCAST(WhTSprite,[liveObjs_ objectForKey:@"background1"]).position = WhTPointMake(0.0f, 0.0f, -5.0f);
			ECCAST(WhTSprite,[liveObjs_ objectForKey:@"background1"]).scale = WhTPointMake(1.0f, 1.0f, 1.0f);
			
			
			
			
			break;
		default:
			break;
	}
}

- (void)doMoreActionsOnStage:(int)s
{
	
}

- (void)dealloc
{
	[stage_ release],stage_ = nil;
	[liveObjs_ release],liveObjs_ = nil;
	[super dealloc];
}

@end
